<?php
/**
 * User: 1971229701@qq.com
 * Date: 2020/9/8/008
 * Time: 10:51
 */

namespace app\common\helper;


class ApiReturn
{
    private static $callResult;
    private static $getInstance;

    //防止使用new直接创建对象
    private function __construct()
    {
        self::$callResult = new CallResult();
    }

    //防止使用clone克隆对象
    private function __clone()
    {
    }

    public static function getInstance()
    {
        if (self::$getInstance instanceof self) {
            return self::$getInstance;
        }
        return self::$getInstance = new self;
    }

    public function apiReturns()
    {
        if (self::$callResult->isSuccess()) {
            return apiReturnSuc(self::$callResult->getData(), self::$callResult->getMsg(), self::$callResult->getCode());
        } else {
            return apiReturnFail(self::$callResult->getMsg(), self::$callResult->getData(), self::$callResult->getCode());
        }
    }
}